package study.encode.hash;

import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import org.apache.commons.codec.digest.DigestUtils;

public class Test {
    public static void main(String[] args) throws Exception {
        String str = "hello";
        System.out.println(Hashing.md5().newHasher().putString(str, Charsets.UTF_8).hash().toString());
        System.out.println(Hashing.sha1().newHasher().putString(str, Charsets.UTF_8).hash().toString());
        System.out.println(Hashing.sha256().newHasher().putString(str, Charsets.UTF_8).hash().toString());

        System.out.println(DigestUtils.md5Hex(str));
        System.out.println(DigestUtils.sha1Hex(str));
        System.out.println(DigestUtils.sha256Hex(str));
        //5d41402abc4b2a76b9719d911017c592 md5
        //aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d sha1
        //2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 sha256
    }
}
